"use strict";
cc._RF.push(module, '1fe34B8jvZLw7FVK4HcWDoE', 'tower_bullet');
// scripts/tower_bullet.js

"use strict";

var e = require;
var t = module;
var o = exports;

var _ii,
    nn = void 0 && (void 0).__extends || (_ii = function ii(t, e) {
  return (_ii = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _ii(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    rr = void 0 && (void 0).__awaiter || function (t, e, o, i) {
  return new (o || (o = Promise))(function (n, a) {
    function r(t) {
      try {
        l(i.next(t));
      } catch (e) {
        a(e);
      }
    }

    function s(t) {
      try {
        l(i["throw"](t));
      } catch (e) {
        a(e);
      }
    }

    function l(t) {
      var e;
      t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
        t(e);
      })).then(r, s);
    }

    l((i = i.apply(t, e || [])).next());
  });
};

var oo = void 0 && (void 0).__decorate || function (e, t, a, n) {
  var i,
      o = arguments.length,
      s = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, a) : n;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);else for (var r = e.length - 1; r >= 0; r--) {
    (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
  }
  return o > 3 && s && Object.defineProperty(t, a, s), s;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});
var a = e("BaseModuleUI"),
    n = e("GlobalParams"),
    i = e("PureHelper"),
    r = e("Game"),
    s = e("role_node"),
    l = e("soldier_node"),
    _ = cc._decorator,
    c = _.ccclass,
    d = (_.property, function (e) {
  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    return t.target_node = null, t;
  }

  return nn(t, e), t.prototype.showTargetInfo = function (e) {
    this.target_node = e, this.node.getComponent(sp.Skeleton).setAnimation(0, "zd", !0);
  }, t.prototype.initView = function () {
    this.towerBulletMove();
  }, t.prototype.towerBulletMove = function () {
    var e = this;

    if (cc.isValid(this.target_node, !0) && this.target_node.active) {
      var t = this.target_node.getPosition();
      t.y += 80;
      var o = this.node.getPosition(),
          a = i["default"].Angle_Y(o, t);
      a = 180 - a, this.node.angle = a;

      var _ = t.sub(o).normalize(),
          c = o.add(_.mul(60));

      cc.tween(this.node).to(n.GlobalParams.GameUpdateTime, {
        position: cc.v2(c.x, c.y)
      }).call(function () {
        i["default"].Distance(c, t) < 50 && (cc.isValid(e.target_node, !0) && ("role" == e.target_node.group ? e.target_node.getComponent(s["default"]).addRoleEffects(r.RoleEffectType.tower_hit) : "soldier" == e.target_node.group && e.target_node.getComponent(l["default"]).addRoleEffects(r.RoleEffectType.tower_hit)), e.node.destroy());
      }).start();
    } else this.node.destroy();

    this.scheduleOnce(function () {
      e.towerBulletMove();
    }, n.GlobalParams.GameUpdateTime);
  }, oo([c], t);
}(a["default"]));
o["default"] = d;

cc._RF.pop();